package com.tarena.lbs.coupon.dao.repository.impl;

import com.tarena.lbs.coupon.dao.mapper.CouponMapper;
import com.tarena.lbs.coupon.dao.repository.CouponRepository;
import com.tarena.lbs.coupon.pojo.po.CouponPO;
import com.tarena.lbs.coupon.pojo.query.CouponQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.List;
@Slf4j
@Repository
public class CouponRepositoryImpl implements CouponRepository {
    @Autowired
    private CouponMapper couponMapper;


    @Override
    public CouponPO getById(Integer couponId) {
        log.debug("根据id查询优惠券信息", couponId);
        CouponPO couponPO = couponMapper.selectById(couponId);
        return couponPO;
    }

    @Override
    public List<CouponPO> couponList(CouponQuery query) {
        log.info("查询所有优惠券,dao层");
        return couponMapper.selectCouponList();
    }



    @Override
    public void addCoupon(CouponPO couponPO) {
        log.info("新增优惠券,dao层");
        couponMapper.insert(couponPO);
    }
    @Override
    public CouponPO detail(Integer id) {
        log.info("查询优惠券详情,dao层"+id);
        return couponMapper.selectById( id);
    }






}
